#!/bin/sh
if [ ! -n "$1" ] ;then  
    echo "请输入项目名"   
    exit 0
fi 
MOUDLE_NAME=$1
PROJECT_NAME="$1-project"
echo "PROJECT_NAME : $PROJECT_NAME"
NEW_BASE_DIR=../$PROJECT_NAME
if [ -d "$$EW_BASE_DIR" ] ;then  
    echo "项目$PROJECT_NAME 已存在"   
    exit 0
fi 
mkdir -p $NEW_BASE_DIR
doCopy(){
   for file in $1/*; do
	if [ -d "$file" ]; then
     dir=${file:2}
     dir=$NEW_BASE_DIR/${dir//bestpl/$MOUDLE_NAME}
     mkdir -p $dir
     echo "mkdir  $dir  ok!!"
     doCopy $file
    elif [ -f $file ]; then
      newfile=${file//bestpl/$MOUDLE_NAME}
      newfile=$NEW_BASE_DIR${newfile:1}
      cp $file $newfile
      echo "copy $newfile OK."
    fi
done
}
doCopy .
echo "创建 $PROJECT_NAME 项目结构成功..."

